﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		PostUrlBuilder.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 // 
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using Dexter.CallContext;
using Dexter.DataTransferObject;
using Dexter.Domain.Model;
using Dexter.Logger.Contracts;

namespace Dexter.Services.Implementation {
	/// <summary>
	/// 	The implementation of <see cref = "IPostUrlBuilder" />.
	/// </summary>
	public class PostUrlBuilder : UrlBuilderBase , IPostUrlBuilder {
		/// <summary>
		/// 	Initializes a new instance of the <see cref = "PostUrlBuilder" /> class.
		/// </summary>
		/// <param name = "logger">The Logger.</param>
		/// <param name = "context">The HTTP context.</param>
		/// <param name = "configurationService">The configuration service.</param>
		public PostUrlBuilder ( ILogger logger , IDexterContext context , IConfigurationService configurationService ) : base ( logger , context , configurationService ) {}

		/// <summary>
		/// 	Return the detail url of the specified <see cref = "Item" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/archive/2009/05/19/My-Post/
		/// </example>
		public virtual string Detail ( Item item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/" , item.PublishDate.Year , item.PublishDate.Month , item.PublishDate.Day , item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// Return the detail url of the specified <see cref="Item"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/archive/2009/05/19/My-Post/
		/// </example>
		public string Detail ( PostDto item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the detail url of the specified <see cref="SearchItem"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/archive/2009/05/19/My-Post/
		/// </example>
		public virtual string Detail ( SearchItem item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the comment url of the specified <see cref="Item"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <returns></returns>
		public string FeedBack ( PostDto item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/#feedback", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the comment url of the specified <see cref="Item"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <returns></returns>
		public string FeedBack ( Item item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/#feedback", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the comment url of the specified <see cref="Item"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <returns></returns>
		public string FeedBack ( PostLightDto item ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/#feedback", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the comment url of the specified <see cref="Item"/>.
		/// </summary>
		/// <param name="c">The item.</param>
		/// <returns></returns>
		public string FeedBack ( CommentDto c ) {
			string dt = string.Format ( "Blog/Post/{0}/{1}/{2}/{3}/#feedback", c.Item.PublishDate.Year, c.Item.PublishDate.Month, c.Item.PublishDate.Day, c.Item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// 	Return the ur for for related contentl of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/related/2009/05/19/My-Post/
		/// </example>
		public virtual string RelatedPosts ( Post item ) {
			string dt = string.Format ( "Blog/Related/{0}/{1}/{2}/{3}/" , item.PublishDate.Year , item.PublishDate.Month , item.PublishDate.Day , item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// Return the ur for for related contentl of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/related/2009/05/19/My-Post/
		/// </example>
		public string RelatedPosts ( PostDto item ) {
			string dt = string.Format ( "Blog/Related/{0}/{1}/{2}/{3}/", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// 	Return the url for the specified month.
		/// </summary>
		/// <param name = "month">The month.</param>
		/// <param name = "year">The year.</param>
		/// <returns></returns>
		/// <example>
		/// 	http://dexterblogengine.com/blog/archives/posts/2010/8/
		/// </example>
		public virtual string ArchivePosts ( int month, int year ) {
			string dt = string.Format ( "Blog/Archive/{0}/{1}/" , year , month );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// 	Return the print url of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/print/2009/05/19/My-Post/
		/// </example>
		public virtual string Print ( Post item ) {
			string dt = string.Format ( "Blog/Print/{0}/{1}/{2}/{3}/" , item.PublishDate.Year , item.PublishDate.Month , item.PublishDate.Day , item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// Return the print url of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/print/2009/05/19/My-Post/
		/// </example>
		public string Print ( PostDto item ) {
			string dt = string.Format ( "Blog/Print/{0}/{1}/{2}/{3}/", item.PublishDate.Year, item.PublishDate.Month, item.PublishDate.Day, item.Slug );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// 	Return the feed url of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/fees/2009/05/19/My-Post/
		/// </example>
		public virtual string Feed ( Post item ) {
			Logger.Warn ( "Method not implemented!" );
			return null;
		}

		/// <summary>
		/// 	Return the statistic url of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/blog/statistics/2009/05/19/My-Post/
		/// </example>
		public virtual string Statistics ( Post item ) {
			Logger.Warn ( "Method not implemented!" );
			return null;
		}

		/// <summary>
		/// 	Return the edit url of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public virtual string Edit ( Post item ) {
			string dt = string.Format ( "Admin/Post/Editor/{0}/" , item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// Return the edit url of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public string Edit ( PostDto item ) {
			string dt = string.Format ( "Admin/Post/Editor/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the edit url of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public virtual string Edit ( SearchItem item ) {
			string dt = string.Format ( "Admin/Post/Editor/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// 	Return the delete url of the specified <see cref = "Post" />.
		/// </summary>
		/// <param name = "item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public virtual string Delete ( Post item ) {
			string dt = string.Format ( "Admin/Post/ConfirmDelete/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage , dt ) );
		}

		/// <summary>
		/// Return the delete url of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public string Delete ( PostDto item ) {
			string dt = string.Format ( "Admin/Post/ConfirmDelete/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}

		/// <summary>
		/// Return the delete url of the specified <see cref="Post"/>.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <example>
		/// 	http://dexterblogengine.com/Admin/Posts/Edit/10/
		/// </example>
		public virtual string Delete ( SearchItem item ) {
			string dt = string.Format ( "Admin/Post/ConfirmDelete/{0}/", item.Id );
			return ToCaseConfiguration ( new Uri ( HomePage, dt ) );
		}
	}
}
